package com.edou.cms.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.edou.base.page.PageResult;
import com.edou.cms.dao.ICmsBlogAuthorTagDao;
import com.edou.cms.entity.CmsBlogAuthorTag;
import com.edou.cms.service.ICmsBlogAuthorTagService;

import com.edou.cms.dto.CmsBlogAuthorTagCondition;

@Service("cmsBlogAuthorTagServiceImpl")
@Transactional(value = "transactionManager")
public class CmsBlogAuthorTagServiceImpl implements ICmsBlogAuthorTagService{

	@Resource(name = "cmsBlogAuthorTagDaoImpl")
	private ICmsBlogAuthorTagDao cmsBlogAuthorTagDao;

	/**
	 * 分页查询
	 * @param pageResult 分页对象
	 * @param condition 查询条件类
	 */
	public void listCmsBlogAuthorTagByPage(PageResult<CmsBlogAuthorTag> pageResult,CmsBlogAuthorTagCondition condition){
		int rows = cmsBlogAuthorTagDao.listCmsBlogAuthorTagByPageCount(condition);
		pageResult.setRows(rows);

		RowBounds rowBounds = new RowBounds(pageResult.getCurrentPageIndex(),pageResult.getPageSize());
		List<CmsBlogAuthorTag> list = cmsBlogAuthorTagDao.listCmsBlogAuthorTagByPage(rowBounds,condition);
		pageResult.setResult(list);
	}

	/**
	 * 根据ID查询
	 * @param id 主键
	 * @return 博主与标签关联表
	 */
	public CmsBlogAuthorTag getCmsBlogAuthorTagById(String id){
		return cmsBlogAuthorTagDao.getCmsBlogAuthorTagById(id);
	}

	/**
	 * 新增
	 * @param item 博主与标签关联表
	 */
	public void add(CmsBlogAuthorTag item){
		cmsBlogAuthorTagDao.add(item);
	}

	/**
	 * 修改
	 * @param item 博主与标签关联表
	 */
	public void update(CmsBlogAuthorTag item){
		cmsBlogAuthorTagDao.update(item);
	}

	/**
	 * 根据ID集合批量删除
	 * @param ids ID集合
	 */
	public void delByIds(String[] ids){
		cmsBlogAuthorTagDao.delByIds(ids);
	}

	/**
	 * 根据博主Id查询标签的集合
	 */
	public List<CmsBlogAuthorTag> listCmsBlogAuthorTagByAuthorId(String authorId) {
		return cmsBlogAuthorTagDao.listCmsBlogAuthorTagByAuthorId(authorId);
	}

	/**
	 * 根据博主id删除标签
	 */
	public void delByAuthorId(String authorId) {
		cmsBlogAuthorTagDao.delByAuthorId(authorId);
	}

}

